#include "readanddestroy.h"
#include "Constants.h"
#include "stringlogger.hpp"
ReadAndDestroy::ReadAndDestroy(const Connectors::PhysicalConnector& p_commport)
    : m_port(p_commport)
{
}

void ReadAndDestroy::readCodes()
{
    m_port.startCommunication();
    std::vector<Message> response;
    response = m_port.send(Data(READMODULE, READMODULE+2));//poprawic senda - echo cancellation

    // if (responce.payload != XX EE XX (np 7F AE 12) znczy zjebalosie - ten konkretny to nie obslugiwana funkcja lub zly format wiadomosci
    LOG << response;
    response = m_port.send(Data(READ_DTC, READ_DTC+2));
    LOG << response;
}
void ReadAndDestroy::readAndDestroy()
{
    readCodes();
    std::vector<Message> response = m_port.send(Data(CLEAR_DTC, CLEAR_DTC+2));
    LOG << response;

}
